﻿#region

using System;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

#endregion

namespace Pob.GameObjects
{
    internal class Endzone : Bande
    {
        // Gibt an, ob es die linke, oder rechte Endzone ist
        #region Fields

        private readonly bool _left;

        // Player, der einen Punkt bekommt, wenn Ball diese Endzone trifft
        private Player _owner;

        private Settings _settings = SettingsManager.CurrentInstance.Settings;

        #endregion

        #region Constructors and Destructors

        public Endzone(Game game, string assetName, Vector2 position, float sizeFactor, float spinAbschwächung, Player owner, bool left)
            : base(game, assetName, position, sizeFactor, spinAbschwächung)
        {
            _owner = owner;

            _left = left;
        }

        #endregion

        #region Public Properties

        public Player Owner
        {
            get
            {
                return _owner;
            }
        }

        #endregion

        #region Public Methods and Operators

        public override void Draw(GameTime gameTime)
        {
            SpriteBatch.Begin();

            if (_left)
            {
                SpriteBatch.Draw(Textur, Position, Color.White);
            }
            else
            {
                SpriteBatch.Draw(Textur, new Vector2(_settings.Width - (Textur.Width / 2f), (_settings.Height / 8f) + (Textur.Height / 2f)), null, Color.White, (float)Math.PI, new Vector2(Textur.Width / 2f, Textur.Height / 2f), 1f, SpriteEffects.None, 0f);
            }

            SpriteBatch.End();
        }

        #endregion
    }
}